package com.fly.service.Impl;

import com.fly.bean.UserLog;
import com.fly.bean.Users;
import com.fly.mapper.UserManageMapper;
import com.fly.service.UserManageService;
import com.fly.util.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class UserManageServiceImpl implements UserManageService {
    @Resource
    private UserManageMapper userManageMapper;

    /**
     * 查询用户的日志信息数量
     * @return
     */
    @Override
    public Integer selectNumberByAllUserLog() {
        return userManageMapper.selectNumberByAllUserLog();
    }

    /**
     * 查询所有用户日志信息分页显示
     * @param page
     * @return
     */
    @Override
    public List<UserLog> selectAllUserLog(Page page) {
        return userManageMapper.selectAllUserLog(page);
    }

    /**
     * 查询用户的日志信息数量通过查询信息
     * @return
     */
    @Override
    public Integer selectNumberByAllUserLogBySelectDate() {
        return userManageMapper.selectNumberByAllUserLogBySelectDate();
    }

    /**
     * 查询所有用户日志信息分页显示通过查询信息
     * @param page
     * @return
     */
    @Override
    public List<UserLog> selectAllUserLogBySelectDate(Page page,String startTime,String endTime) {
        return userManageMapper.selectAllUserLogBySelectDate(page,startTime,endTime);
    }

    /**
     * 查询用户表中的数量
     * @return
     */
    @Override
    public Integer selectUsersNumber() {
        return userManageMapper.selectUsersNumber();
    }

    /**
     * 查询所有的用户名称用于循环查找用户最后登录时间
     * @return
     */
    @Override
    public String[] selectUserName(Page page) {
        return userManageMapper.selectUserName(page);
    }

    /**
     * 根据用户名查询对应的最后登录时间
     * @param userName
     * @return
     */
    @Override
    public String selectLastTimeByUserName(String userName) {
//        System.out.println("service" + userName);
        return userManageMapper.selectLastTimeByUserName(userName);
    }

    /**
     * 查询用户状态信息根据用户的userId
     * @return
     */
    @Override
    public String[] selectSysProValueNameByUserId(Page page) {
        return userManageMapper.selectSysProValueNameByUserId(page);
    }

    /**
     * 查询所有的用户信息分页显示
     * @param page
     * @return
     */
    @Override
    public List<Users> selectAllUsers(Page page) {
        return userManageMapper.selectAllUsers(page);
    }

    /**
     * 通过条件查询用户表中的数量
     * @param userName
     * @param sysProValueName
     * @return
     */
    @Override
    public Integer selectUsersNumberByUserNameAndSysProValueName(String userName,String sysProValueName) {
        return userManageMapper.selectUsersNumberByUserNameAndSysProValueName(userName,sysProValueName);
    }

    /**
     * 通过条件查询所有的用户名称用于循环查找用户最后登录时间
     * @param userName
     * @param page
     * @return
     */
    @Override
    public String[] selectUserNameByUserNameAndSysProValueName(String userName,Page page) {
        return userManageMapper.selectUserNameByUserNameAndSysProValueName(userName,page);
    }

    /**
     * 通过条件查询用户状态信息根据用户的userId
     * @param userName
     * @param sysProValueName
     * @return
     */
    @Override
    public String[] selectSysProValueNameByUserIdAndUserNameAndSysProValueName(String userName, String sysProValueName,Page page) {
        return userManageMapper.selectSysProValueNameByUserIdAndUserNameAndSysProValueName(userName,sysProValueName,page);
    }

    /**
     * 通过条件查询所有的用户信息分页显示
     * @param page
     * @param userName
     * @param sysProValueName
     * @return
     */
    @Override
    public List<Users> selectAllUsersByUserNameAndSysProValueName(Page page,String userName, String sysProValueName) {
        return userManageMapper.selectAllUsersByUserNameAndSysProValueName(page,userName,sysProValueName);
    }

    /**
     * 查询用户名是否存在
     * @param userName
     * @return
     */
    @Override
    public String selectUserNameExists(String userName) {
        return userManageMapper.selectUserNameExists(userName);
    }

    /**
     * 查询用户状态信息根据sysProValueName
     * @param sysProValueName
     * @return
     */
    @Override
    public Integer selectUserStateBySysProValueName(String sysProValueName) {
        return userManageMapper.selectUserStateBySysProValueName(sysProValueName);
    }

    /**
     * 查询角色ID根据角色名称
     * @param roleName
     * @return
     */
    @Override
    public Integer selectRoleIdByRoleName(String roleName) {
        return userManageMapper.selectRoleIdByRoleName(roleName);
    }

    /**
     * 添加用户信息
     * @param users
     * @return
     */
    @Override
    public Integer addUserMessage(Users users) {
        return userManageMapper.addUserMessage(users);
    }

    /**
     * 添加用户日志信息
     * @param userLog
     * @return
     */
    @Override
    public Integer addUserLog(UserLog userLog) {
        return userManageMapper.addUserLog(userLog);
    }

    /**
     * 修改用户信息
     * @param user
     * @return
     */
    @Override
    public Integer modifyUserMessageByUserId(Users user) {
        return userManageMapper.modifyUserMessageByUserId(user);
    }

    /**
     * 删除用户信息
     * @param userId
     * @return
     */
    @Override
    public Integer deleteUserMessage(Integer userId) {
        return userManageMapper.deleteUserMessage(userId);
    }

    /**
     * 通过用户ID查询该用户的所有信息
     * @param userId
     * @return
     */
    @Override
    public Users selectUserByUserId(Integer userId) {
        return userManageMapper.selectUserByUserId(userId);
    }

    /**
     * 修改用户状态
     * @param userState
     * @return
     */
    @Override
    public Integer modifyUserState(Integer userState,Integer userId) {
        return userManageMapper.modifyUserState(userState, userId);
    }

    /**
     * 根据用户Id查询角色Id
     * @param userId
     * @return
     */
    @Override
    public Integer selectRoleIdByUserId(Integer userId) {
        return userManageMapper.selectRoleIdByUserId(userId);
    }

    /**
     * 根据角色Id查询角色名称
     * @param roleId
     * @return
     */
    @Override
    public String selectRoleNameByRoleId(Integer roleId) {
        return userManageMapper.selectRoleNameByRoleId(roleId);
    }

    /**
     * 根据用户Id查询用户名
     * @param userId
     * @return
     */
    @Override
    public String selectUserNameByUserId(Integer userId) {
        return userManageMapper.selectUserNameByUserId(userId);
    }

    /**
     * 根据状态信息查询用户名
     * @param userState
     * @return
     */
    @Override
    public String[] selectUserNameByUserState(Integer userState,Page page) {
        return userManageMapper.selectUserNameByUserState(userState,page);
    }
}
